﻿using System;
using System.Web.Mvc;
using System.Runtime.Serialization;

namespace Sencha.Direct
{
	public class ErrorActionResult : DirectJsonResult
	{
		new public JsError Data { get { return (JsError)base.Data; } set { base.Data = value; } }
		public override Type DataType { get { return typeof(JsError); } }

		public ErrorActionResult()
			:this(new JsError())
		{
			
		}
		public ErrorActionResult(string name, string message)
			:this(new JsError(name, message))
		{

		}
		public ErrorActionResult(Exception exc)
			:this(new JsError(exc))
		{

		}
		public ErrorActionResult(JsError error)
		{
			if (error == null)
				throw new ArgumentNullException("error");

			this.Data = error;
		}

		public override string ToString()
		{
			return Convert.ToString(this.Data);
		}
	}
}
